//
// Created by xdc on 2025/11/7.
//
//用户界面入口

#include "user_query.h"
#include "admin_select.h"
int clear_buffer4() {
    int c;
    while ((c = getchar()) != '\n' && c != EOF);
}
int user_query_entry(){
    printf("欢迎进入用户查询界面！\n");
    user_query_menu();
}
int user_query_menu(){
    int running =1;
    while (running) {
        printf("===============用户查询菜单==============\n");
        printf("1.根据图书名字查询 2.根据图书作者查询 \n3.根据图书类别查询(科幻，文艺，经济） 4.返回用户菜单\n");
        printf("请输入选择（1-4）：");
        int choose;
        if (scanf("%d",&choose)!=1||choose<=0){
            printf("请输入有效的数字\n");
            clear_buffer4();
        }
        switch (choose) {
            case 1:
                name_select();
                break;
            case 2:
                author_select();
                break;
            case 3:
                category_id_select();
                break;
            case 4:
                running = 0;
                printf("返回用户菜单！\n");
                break;
            default:
                printf("输入错误，请重新输入!\n");
                break;
        }
    }
}